<html>
<head><meta charset="utf-8"><title>Why does tcx.parent(`pub use`) give `None`?` · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20does.20tcx.2Eparent(.60pub.20use.60).20give.20.60None.60.3F.60.html">Why does tcx.parent(`pub use`) give `None`?`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208451791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20does%20tcx.parent%28%60pub%20use%60%29%20give%20%60None%60%3F%60/near/208451791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20does.20tcx.2Eparent(.60pub.20use.60).20give.20.60None.60.3F.60.html#208451791">(Aug 29 2020 at 20:13)</a>:</h4>
<p>On this code:</p>
<div class="codehilite"><pre><span></span><code><span class="sd">/// [`std::fs`]</span>
<span class="k">pub</span><span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">foo2</span><span class="p">;</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(){}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>


<p><code>tcx.parent()</code> gives <code>None</code> on <code>pub use foo as foo2</code>. Why? Shouldn't it give the current module?</p>



<a name="208452032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20does%20tcx.parent%28%60pub%20use%60%29%20give%20%60None%60%3F%60/near/208452032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20does.20tcx.2Eparent(.60pub.20use.60).20give.20.60None.60.3F.60.html#208452032">(Aug 29 2020 at 20:19)</a>:</h4>
<p>oh hold on, I think this might be calling parent() on the root module, not on the <code>use</code> <span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span></p>



<a name="208452331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20does%20tcx.parent%28%60pub%20use%60%29%20give%20%60None%60%3F%60/near/208452331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20does.20tcx.2Eparent(.60pub.20use.60).20give.20.60None.60.3F.60.html#208452331">(Aug 29 2020 at 20:25)</a>:</h4>
<p>yeah that was it, every thing works fine now</p>



<a name="208460961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20does%20tcx.parent%28%60pub%20use%60%29%20give%20%60None%60%3F%60/near/208460961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tshepang Lekhonkhobe <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20does.20tcx.2Eparent(.60pub.20use.60).20give.20.60None.60.3F.60.html#208460961">(Aug 30 2020 at 00:24)</a>:</h4>
<p>(deleted)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>